@section('title', "题库管理")
@section('content_title', '题库管理')
@section('content_title_small', isset($item->id) ? "编辑User Id: $item->id " : "增加")
@section('css')
    <link rel="stylesheet" href="{{ $assets_url}}/static/plugins/select2/select2.min.css">
    @endsection
    @section('content')
            <!-- Main content -->
    <section class="content" id="pjax-container">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-success">
                    <div class="box-body" style="display: block;">
                        <form method="POST" id="form" action="{{ url('/issue') }}" class="form-horizontal"
                              accept-charset="UTF-8" pjax-container="">
                            <input type="hidden" name="id" value="{{ isSet($item->id) ? $item->id : 0 }}">

                            <div class="box-body">
                                <div class="form-group">
                                    <label for="mobile" class="col-sm-2 control-label">所属</label>

                                    <div class="col-sm-10">
                                        <select class="form-control" name="course">
                                            @foreach($course as $c)
                                                 <option value="{{$c->id}}" @if( isset($item->course_id)&&$c->id == $item->course_id) selected @endif  >{{$c->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="role" class="col-sm-2 control-label">题目</label>

                                    <div class="col-sm-10">
                                        <textarea name="question" cols=100 rows=5
                                                  class="form-control">{{ isSet($item->question) ? $item->question : "" }}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="type" class="col-sm-2 control-label">类型</label>

                                    <div class="col-sm-10">
                                        <select class="form-control" name="type" id="type">
                                            <option value="27" selected>单选</option>
                                            {{--<option value="28"--}}
                                            {{--@if(isSet($item->type) && $item->type ==28) selected @endif>多选--}}
                                            {{--</option>--}}
                                            <option value="29"
                                                    @if(isSet($item->type) && $item->type ==29) selected @endif>判断
                                            </option>
                                        </select>
                                    </div>
                                </div>
                                <style>
                                    .module-radio:before {
                                        cursor: pointer;
                                        background-color: #f6f6f6;
                                        padding: 7px 12px;
                                        border-radius: 25px;
                                        margin-left: -15px;
                                    }

                                    .radio-a:before {
                                        content: 'A';
                                    }

                                    .radio-b:before {
                                        content: 'B';
                                    }

                                    .radio-c:before {
                                        content: 'C';
                                    }

                                    .radio-d:before {
                                        content: 'D';
                                    }

                                    .radio-true:before {
                                        content: '√';
                                    }

                                    .radio-false:before {
                                        content: '×';
                                    }

                                    .checked:before {
                                        background-color: #00a65a;
                                        color: #f6f6f6;
                                    }

                                </style>
                                <!--单选模块-->
                                @include('admin.common.radio',isSet($item->id)?$item:[])
                                        <!--多选模块-->
                                {{--@include('admin.common.checkbox',$item)--}}
                                <!--多选模块-->
                                @include('admin.common.judge',isSet($item->id)?$item:[])

                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <button type="button" class="btn btn-cancel pull-left"
                                        onclick="location='{{ url("/issue") }}';">返回
                                </button>
                                <button type="submit" class="btn btn-info pull-right _submit_" data-form-id="form"
                                        data-refresh-url="{{ url("/issue") }}">提交
                                </button>
                            </div>
                        </form>
                    </div><!-- /.box-body -->
                </div>
            </div>
        </div>
    </section>
@endsection
@section('js')
    <script>
        $(function () {
            $('#type').change(function () {
                var radio = $("#module-radio");
                var checkbox = $("#module-checkbox");
                var judge = $("#module-judge");
                var id = $(this).val();
                if (id == 27) {
                    radio.show();
                    checkbox.hide();
                    judge.hide();
                } else if (id == 28) {
                    radio.hide();
                    checkbox.show();
                    judge.hide();
                } else {
                    radio.hide();
                    checkbox.hide();
                    judge.show();
                }
            });

            $(function () {
                $('input[type=radio][name=radio]').change(function () {
                    $(this).parents('.module').find('.checked').removeClass('checked');
                    $(this).addClass('checked');
                });
                $('input[type=checkbox][name=checkbox]').change(function () {
                    if ($(this).hasClass('checked')) {
                        $(this).removeClass('checked');
                    } else {
                        $(this).addClass('checked');
                    }
                });
                $('input[type=radio][name=judge]').change(function () {
                    $(this).parents('.module').find('.checked').removeClass('checked');
                    $(this).addClass('checked');
                });
            });

        });
    </script>
@endsection
@extends('layouts.admin')